/**
 * ****************************** ICE *******************************
 * ========================================================================
 * Project: iceutil 
 * Package: org.ice4apps.util 
 * File: Util.java 
 * Author: robin 
 * Date: Nov 25, 2008 
 * Description:
 * ========================================================================
 */
package org.ice4apps.util;

public final class Util {
    /**
     * Appends the objects passed and return appended string
     * 
     * @param objects
     * @return String
     */
    public static String append (Object... objects) {
        final StringBuilder buff = new StringBuilder ();
        for (final Object obj : objects)
            buff.append (obj);
        return buff.toString ();
    }
    
    /**
     * @param id [ id]
     * @param value [current  value]
     * @param flag [ enable/disable]
     * @return new  value
     */
    public static long setFlag (int id, long value,  boolean flag) {
        return flag ? (Long.rotateLeft (1, id) | value) : (~(Long.rotateLeft (1, id)) & value);
    }
    
    /**
     * @param id
     * @param values [current  values]
     * @return boolean [flag status]
     */
    public static boolean getFlag (int id, long... values) {
        final long a = Long.rotateLeft (1, id);
        for (long value : values)
            if ((value & a) == 0)
                return false;
        return true;
    }
}
